//
//  DetailMessageViewController.m
//  UserUse
//
//  Created by angra on 16/10/18.
//  Copyright © 2016年 CJPC. All rights reserved.
//

#import "DetailMessageViewController.h"
#import "SystemMessageModel.h"
@interface DetailMessageViewController ()

@end

@implementation DetailMessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"消息详情";
    [self setInterface];
}
-(void)setInterface
{
    UIScrollView *backScrollView = [[UIScrollView alloc]init];
    backScrollView.backgroundColor = kColoeString(@"ffffff");
    [self.view addSubview:backScrollView];
    [backScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.and.right.equalTo(self.view);
    }];
    
    
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel.numberOfLines = 0;
    titleLabel.text = _model.title;
    titleLabel.font = [UIFont systemFontOfSize:kScaleNum(15)];
    titleLabel.textColor = kColoeString(@"333333");
    [backScrollView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(backScrollView.mas_top).with.offset(kScaleNum(15/2));
        make.left.equalTo(backScrollView.mas_left).with.offset(kScaleNum(10));
        make.width.equalTo(@(kScreenFrameW-kScaleNum(20)));
//        make.height.equalTo(@(kScaleNum(64/2)));
    }];
    
    UILabel *timeLabel = [[UILabel alloc]init];
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    formatter.timeZone = [NSTimeZone timeZoneWithName:@"shanghai"];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"yyyy年MM月dd日 HH:ss"];
    
    // 毫秒值转化为秒
    NSDate* date = [NSDate dateWithTimeIntervalSince1970:[_model.createTime doubleValue]/ 1000.0];
    NSString* dateString = [formatter stringFromDate:date];
    timeLabel.text = dateString;
//    timeLabel.textAlignment = NSTextAlignmentRight;
    timeLabel.font = FontSize(kScaleNum(12));
    timeLabel.textColor = kColoeString(@"999999");
    [backScrollView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLabel.mas_bottom).with.offset(kScaleNum(10));
        make.left.equalTo(titleLabel);
        make.width.equalTo(titleLabel);
        make.height.equalTo(@(kScaleNum(12)));
    }];
    
    UILabel *contentLabel = [[UILabel alloc]init];
    contentLabel.numberOfLines = 0;
    contentLabel.text = self.model.content;
    contentLabel.font = FontSize(kScaleNum(12));
    contentLabel.textColor = kColoeString(@"333333");
    [backScrollView addSubview:contentLabel];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(timeLabel.mas_bottom).with.offset(kScaleNum(10));
        make.left.equalTo(titleLabel);
        make.right.equalTo(titleLabel);
        make.height.lessThanOrEqualTo(backScrollView).offset(10);
    }];
    
    [backScrollView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(contentLabel).offset(10);
    }];
  
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
